<template>
  <div class="info" v-loading="loading">
    <div class="card_con mb15">
      <el-row class="mb15">
        <el-col :span="5" class="pr40">
          <div class="fz13 mb10">订单号：</div>
          <el-input v-model="orderId" placeholder="请输入订单号"></el-input>
        </el-col>
        <el-col :span="5" class="pr40">
          <div class="fz13 mb10">发货状态：</div>
          <el-select clearable v-model="deliverId" placeholder="请选择">
            <el-option
              v-for="item in deliverArr"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
          <!-- <el-input v-model="orderId" placeholder="请输入订单号"></el-input> -->
        </el-col>
        <el-col :span="9" class="pr40">
          <div class="fz13 mb10">时间</div>
          <el-date-picker
            value-format="yyyy-MM-dd HH:mm:ss"
            v-model="time"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-col>
        <el-col :span="4">
          <div class="fz13 mb10">&nbsp;</div>
          <el-button type="primary" @click="handleQuery">查询</el-button>
        </el-col>
      </el-row>
    </div>
    <div class="card_con">
      <el-table
        border
        :data="tableData"
        :header-cell-style="{
          'text-align': 'center',
        }"
        :cell-style="{ 'text-align': 'center' }"
        style="width: 100%"
        highlight-current-row
      >
        <!-- <el-table-column type="selection" min-width="15%"> </el-table-column> -->
        <el-table-column prop="id" label="id" min-width="15%">
        </el-table-column>
        <el-table-column prop="oid" label="订单号" min-width="25%">
        </el-table-column>
        <el-table-column
          prop="prices.integral"
          label="荟金抵扣"
          min-width="15%"
        >
        </el-table-column>
        <el-table-column prop="prices.redbao" label="红包抵扣" min-width="15%">
        </el-table-column>
        <el-table-column
          prop="prices.org_total"
          label="订单金额"
          min-width="15%"
        >
        </el-table-column>
        <el-table-column prop="prices.total" label="支付金额" min-width="15%">
        </el-table-column>
        <el-table-column
          prop="times.create_time"
          label="下单时间"
          min-width="25%"
        >
        </el-table-column>
        <el-table-column label="状态" min-width="25%">
          <template slot-scope="scope">
            <div v-if="scope.row.status === '已取消'">已取消</div>
            <div v-if="scope.row.status === '待支付'" class="red">待支付</div>
            <div v-if="scope.row.status === '待消费'" class="green">待消费</div>
            <div v-if="scope.row.status === '已消费'" class="green">已消费</div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <Pagination :page="page" @onCurrentChange="handleCurrentChange" />
      </div>
    </div>
  </div>
</template>

<script>
import Dialog from "./order_detail.vue";
import Pagination from "@/components/Pagination.vue";
import { offlineOrder } from "@/api/shopSystem";
export default {
  components: { Pagination, Dialog },
  data() {
    return {
      loading: true,
      orderId: "",
      time: "",
      page: {
        total: 0,
        pageNum: 1, // 当前页数
        pageSize: 10, // 每页的条数
      },
      title: "",
      deliverId: "",
      deliverArr: [
        { id: "待支付", name: "待支付" },
        { id: "待消费", name: "待消费" },
        { id: "已消费", name: "已消费" },
      ],
      tableData: [
        {
          id: "1",
          hf_id: "123243",
          tel: "18582669937",
          location: "成都市武侯区",
          logo: require("@/assets/1.png"),
          leixing: "入驻",
          status: "启用",
          create_time: "2022-5-19",
        },
      ],
      rowData: {}, //当前行数据 传给详情
    };
  },
  methods: {
    //订单列表
    async offlineOrder() {
      const { data, err } = await offlineOrder({
        page: this.page.pageNum,
        oid: this.orderId,
        st_: this.time ? this.time[0] : 0,
        se_: this.time ? this.time[1] : 0,
        status: this.deliverId,
      });
      if (err === 0) {
        this.loading = false;
        this.tableData = data.data;
        this.page.pageSize = data.per_page;
        this.page.total = data.total;
      }
    },
    //查询
    handleQuery() {
      this.loading = true;
      //调接口
      this.page.pageNum = 1;
      this.offlineOrder();
    },
    handleCurrentChange(val) {
      this.page.pageNum = val;
      this.offlineOrder();
    },
  },
  created() {
    this.offlineOrder();
  },
};
</script>

<style lang="scss" scoped>
@import "@/style/index.scss";

.info {
  .title {
    font-size: 16px;
    margin-bottom: 13px;
  }
}
.pagination {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}
.el-select {
  width: 100%;
}

.tb {
  background-color: #fff;
  padding: 20px;
  box-sizing: border-box;
}
.row {
  display: flex;
  border-radius: 2px;
  border: 1px solid #ccc;
  width: 80px;
  .l {
    width: 80px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;

    i {
      margin-right: 6px;
      font-size: 18px;
    }
    &:hover {
      cursor: pointer;
    }
  }
  .l:nth-child(3) {
    border-right: 0;
  }
}
.editDialog {
  //   z-index: 2005 !important;
  /deep/.el-dialog {
    height: 75%;
    .el-dialog__body {
      height: 78%;
      overflow: auto;
    }
  }
}
</style>
